﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BPM.Entity;
using System.Data.Entity.ModelConfiguration;

namespace BPM.Service.Mappings
{
	internal class UserConfiguration : EntityConfiguration<User>
	{
		public UserConfiguration()
		{
			this.HasRequired(u => u.Barcode)
				.WithMany()
				.HasConstraint((u, b) => u.BarcodeId == b.Id)
				.WillCascadeOnDelete(false);
			this.HasMany(u => u.RoleList).WithMany()
				.Map("User_Roles", (u, r) => new
				{
					UserId = u.Id,
					RoleId = r.Id
				});
			//user.MapSingleType(u => new
			//{
			//    u.Id,
			//    u.UserName,
			//    u.Password,
			//    u.RealName,
			//    u.BarcodeId
			//}).ToTable("Users");
		}
	}
}
